
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit" />
    <meta name="robots" content="index, follow" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/font-awesome.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/bootstrap.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/owl.carousel.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/magnific-popup.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/animate.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/settings.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/style-red.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="qtimages/css/tk.css" media="screen" />
    <script type="text/javascript" src="qtimages/js/jquery.min.js"></script>
    <script type="text/javascript" src="qtimages/js/jquery.migrate.js"></script>
    <script type="text/javascript" src="qtimages/js/bootstrap.js"></script>
    <script type="text/javascript" src="qtimages/js/owl.carousel.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#navigation #nav_0 .menu1").addClass("active");
        });
    </script>
    <link rel="stylesheet" href="./qtimages/sl_common_form.css">
    <title>帖子</title>
</head>
<body>
<div id="wrapper">
<div id="container">
    <script src="qttop.js"></script>
    <script src="bht.js"></script>
    <div id="content">

    <div class="section-content team-section2 no-padd" id="index-news">
        <div class="title-section title2">
            <div class="container triggerAnimation animated" data-animate="bounceIn">
                <h1>帖子</h1>
            </div>
        </div>
        <div class="team-box">
            <div class="container">
                <div class="row">
                    <div class="content-form">

						<div style="margin-top: 10px">
								<div style="border: 1px solid #ff6b31;">
									<div style="padding: 5px; border-bottom: 1px solid #ff6b31; color: white; background-color: #ff6b31;">帖子</div>
									<div style="border: 1px solid #ccc; padding: 10px">
										<div class="table-responsive">
											<div class="nx-table-header" style="position: relative">

												<input type="text" placeholder="请输入搜索内容" v-model="name" @keyup.enter="loadTable(1)">
												<i class="glyphicon glyphicon-search" style="margin-left: -20px"></i>
												&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-sm btn-primary" v-on:click="add()">我要发帖</button>
											</div>
											<table class="table table-striped table-bordered table-hover">
												<thead>
												<tr>
													<th>ID</th>
													<th >所在版块</th>
    <th >标题</th>
    
    <th >类型</th>
    <th >发布人</th>
    <th >回帖数</th>
    
													<th>操作</th>
												</tr>
												</thead>
												<tbody v-for="obj in objs">
												<tr>
													<td>{{obj.id}}</td>
													<td>{{obj.suozaibankuai}}</td>
    <td>{{obj.biaoti}}</td>
    
    <td><img width='30'height='30' :src="'bbs/'+obj.leixing+'.gif'" border=0> </td>
    <td>{{obj.faburen}}</td>
    <td>{{obj.huitieshu}}</td>
    

													<td>
														<button class="btn btn-primary btn-xs" @click="detail(obj.id)">详细</button>                                </td>
												</tr>
												</tbody>
											</table>
											<!--danhxexiaxnshi-->
											<nav aria-label="Page navigation example">
												<ul class="pagination">
													<li class="page-item" v-bind:class="{ disabled: preActive }">
														<a class="page-link" href="javascript:void(0)"
														   v-on:click="loadTable(pageInfo.pageNum - 1)">上一页</a>
													</li>
													<li class="page-item">
														<a class="page-link" href="javascript:void(0)" v-if="pageInfo.pageNum > 1" v-on:click="loadTable(pageInfo.pageNum - 1)">{{pageInfo.pageNum - 1}}</a>
													</li>
													<li class="page-item disabled">
														<a class="page-link" aria-disabled="true" href="javascript:void(0)">{{pageInfo.pageNum}}</a>
													</li>
													<li class="page-item">
														<a class="page-link" href="javascript:void(0)" v-if="pageInfo.hasNextPage" v-on:click="loadTable(pageInfo.pageNum + 1)">{{pageInfo.pageNum + 1}}</a>
													</li>
													<li class="page-item" v-bind:class="{ disabled: nextActive }">
														<a class="page-link" href="javascript:void(0)" v-on:click="loadTable(pageInfo.hasNextPage? (pageInfo.pageNum + 1) : pageInfo.pageNum)">下一页</a>
													</li>
												</ul>
											</nav>
										</div>
									</div>
								</div>
							</div>
						
                    </div>
                </div>
            </div>
        </div>
    </div>
        <script src="sidebufen.js"></script>

		<div class="modal" tabindex="-1" role="dialog" id="mod">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<span class="modal-title">请填写信息</span>
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
					</div>
					<div class="modal-body">
						<form class="form-horizontal">
							<input type="hidden" id="id" name="id" v-model="entity.id">
							<div  class="form-group"><label class="col-sm-3 control-label">所在版块</label><div class="col-sm-7"><input type="text" class="form-control" v-model="entity.suozaibankuai" style="width: 160px" placeholder="请输入所在版块" id="suozaibankuai"></div></div>
							<div  class="form-group"><label class="col-sm-3 control-label">标题</label><div class="col-sm-7"><input type="text" class="form-control" v-model="entity.biaoti"  placeholder="请输入标题" id="biaoti"></div></div>
							<div  class="form-group"><label class="col-sm-3 control-label">内容</label><div class="col-sm-7"><textarea type="text" class="form-control" v-model="entity.neirong" style="height: 100px" placeholder="请输入内容" id="neirong"></textarea></div></div>
							<div  class="form-group"><label class="col-sm-3 control-label">类型</label><div class="col-sm-7">

								<input id="leixing" v-model="entity.leixing" type="radio" value="putong" checked  >
								<img src="bbs/putong.gif" width="30" height="30">
								<input type="radio" v-model="entity.leixing" id="leixing" value="jiaji">
								<img src="bbs/jiaji.gif"  width="30" height="30">
								<input type="radio" v-model="entity.leixing" id="leixing" value="qiuzhu">
								<img src="bbs/qiuzhu.gif" width="30" height="30">
								<input type="radio" v-model="entity.leixing" id="leixing" value="tuijian">
								<img src="bbs/tuijian.gif" width="30" height="30">


							</div></div>
							<div  class="form-group"><label class="col-sm-3 control-label">发布人</label><div class="col-sm-7"><input type="text" class="form-control" v-model="entity.faburen" style="width: 160px" placeholder="请输入发布人" id="faburen" disabled></div></div>

						</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>

						<button type="button" class="btn btn-primary" @click="update()">保存</button>
					</div>
				</div>
			</div>
		</div>
</div>
<script src="qtdown.js"></script></div>
<script type="text/javascript" src="qtimages/js/jquery.magnific-popup.min.js"></script>
<script type="text/javascript" src="qtimages/js/jquery.appear.js"></script>
<script type="text/javascript" src="qtimages/js/jquery.imagesloaded.min.js"></script>
<script type="text/javascript" src="qtimages/js/jquery.isotope.min.js"></script>
<script type="text/javascript" src="qtimages/js/retina-1.1.0.min.js"></script>
<script type="text/javascript" src="qtimages/js/plugins-scroll.js"></script>
<script type="text/javascript" src="qtimages/js/waypoint.min.js"></script>
<script type="text/javascript" src="qtimages/js/jquery.themepunch.tools.min.js"></script>
<script type="text/javascript" src="qtimages/js/jquery.themepunch.revolution.min.js"></script>
<script type="text/javascript" src="qtimages/js/script.js"></script>
<link type="text/css" rel="stylesheet" href="qtimages/css/jquery.mmenu.all.css" />
<script type="text/javascript" src="qtimages/js/jquery.mmenu.all.min.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function($) {
        var mmenu = $('nav#mmenu').mmenu({
            slidingSubmenus: true,
            classes: 'mm-white',
            //mm-fullscreen mm-light
            extensions: ["theme-white"],
            offCanvas: {
                position: "right",
                //left, top, right, bottom
                zposition: "front" //back, front,next
                //modal		: true
            },
            searchfield: false,
            counters: false,
            //navbars		: {
            //content : [ "prev", "title", "next" ]
            //},
            navbar: {
                title: "网站导航"
            },
            header: {
                add: true,
                //update: true,
                title: "网站导航"
            }
        });
        $(".closemenu").click(function() {
            var mmenuAPI = $("#mmenu").data("mmenu");
            mmenuAPI.close();
        });
    });
</script>
<!--daipxingxlun-->
</div>
<script src="js/swiper-5.4.5/swiper.min.js"></script>
<script src="js/vue2.6.11/axios.js"></script>
<script src="js/vue2.6.11/vue.min.js"></script>
<script src="js/my.js"></script>
<script src="js/element/index.js"></script>


<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/nav.css">
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/element/index.css">
<link rel="stylesheet" href="css/hsg.css">
<script>
	function checkValid(entity) {
		if (!entity.suozaibankuai || entity.suozaibankuai === "") {alert("所在版块不能为空"); return false;}
		if (!entity.biaoti || entity.biaoti === "") {alert("标题不能为空"); return false;}
		if (!entity.leixing || entity.leixing === "") {alert("请选择类型"); return false;}

		return true;
	}
	new Vue({
		el: '#wrapper',
		data: {
			authority: [],
			permission: [],
			storeUser: JSON.parse(localStorage.getItem("user")),
			name: '',
			bk: '',

			//tieziInfo: {},
			huitie: [],
			commentInfo: {
				tieziid: 0,
				content: ''
			},
			// gonghao: '',
			//xingming:'',
			user: {},
			searchText: null,
		
//youtupianimrl
			objs: [],
			pageInfo: {},
			preActive: true,
			nextActive: true,
			isShow: false,
//youtupianavt
			entity: {

			}
		},
		created: function () {
			axios.get('/auth').then(res => {
				if (res.data.code === '0') {
					this.user = res.data.data;

				}else {
					alert('请先登录');
					location.href = '/front/index.html';
				}
			});

			this.user = JSON.parse(localStorage.getItem('user'));
			if (this.user.level === "注册用户"){this.entity.faburen = this.user.yonghuming;}

			if (this.user.level === "管理员"){this.entity.faburen = this.user.username;}


			this.loadTable(1);
			debugger
			const bk = this.getQueryVariable('bk');
			this.entity.suozaibankuai=decodeURI(bk);
		},
		methods: {
			loadTable(pageNum) {
				let name = this.name === '' ? "all" : this.name;

				//this.bk = this.getQueryVariable('bk');
				axios.get("/tieziInfo/pagebbs/" + name + "/"+this.getQueryVariable('bk')+"?pageNum=" + pageNum).then(res => {
					if (res.data.code === '0') {
						this.objs = res.data.data.list;
						res.data.data.list.forEach(item=>{

							//if(item.zhaopian) {item.zhaopianavt = JSON.parse(item.zhaopian)[0];}
							//tupianloadtb
							//dhjsuanxx
						})
						this.pageInfo = res.data.data;
						this.preActive = !(this.pageInfo.hasPreviousPage);
						this.nextActive = !(this.pageInfo.hasNextPage);
					} else {
						msg('error', res.data.msg);
					}
				});
			},
			getQueryVariable(variable) {
				let query = window.location.search.substring(1);
				let vars = query.split("&");
				for (let i = 0; i < vars.length; i++) {
					let pair = vars[i].split("=");
					if (pair[0] === variable) {
						return pair[1];
					}
				}
				return '';
			},

			searchShangpinxinxi(text) {   // 根据关键字查询商品
				if(text) {
					location.href = '/front/tiezilisttp.html?text=' + text;
				}else {
					location.href = '/front/tiezilisttp.html';
				}
			},
			openModel() {
				if(this.user.level+"" == 'undefined'){
					alert("请先登录");
					return;
				}
				//this.tieziInfo.tieziid = this.tieziid;
				//this.tieziInfo.neirong = '';
				$('#mod').modal('show');
			},
			detail(id){
				window.location = "tiezidetail.html?tieziid="+id;
			},
			qiehuanshitu()
			{
				window.location = "tiezilisttp.html";
			},
			add() {
				//if (this.user.level === "管理员")
//                {}
//                else
//                {
//                    msg('warning', '你没有权限操作');
//                    return;
//                }




				$('#mod').modal('show');


			},
			update() {

				if (checkValid(this.entity)) {
					debugger
					if (!this.entity.id) {

						axios.post(
								"/tieziInfo", this.entity
						).then(res => {
							if (res.data.code === '0') {
								msg('success', '添加成功');
								$('#mod').modal('hide');
								this.loadTable(1);
							} else {
								msg('error', res.data.msg);
							}
						})
					}
				}

			},
			//m_tupiansccsbaul
			logout() {
				axios.get("/logout").then(res => {
					if(res.data.code === '0') {
						location.href = '/front/index.html';
					} else {
						msg('error', res.data.msg);
					}
				})
			}
		}
	})
</script>
</body>
</html>
